<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../_include/lib.jsp" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>实时检测</title>
	<%@include file="../_include/style.jsp" %>
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content">
		<div class="row">
			<div class="col-md-12">
				<select id="chosenShelfList" data-placeholder="选择机架" class="chosen-select">
					<c:forEach var="shelf" items="${_shelfs }">
						<option value="${shelf.id }">${shelf.name }</option>
					</c:forEach>
				</select>
				<button id="btnDetect" type="button" class="btn btn-primary">
					开始检测
                </button>
			</div>
		</div>
		<div class="row show-grid">
			<div class="col-xs-1 grid-item-1">
				矿机总数 : ${_detail.numDetect} / ${_detail.numAll }
			</div>
			<div class="col-xs-1 grid-item-1">
				检测到 : ${_detail.numDetail}
			</div>
			<div class="col-xs-1 grid-item-1">
				合格数 : ${_detail.numPassed}
			</div>
			<div class="col-xs-1 grid-item-1">
				不合格数 : ${_detail.numUnpassed}
			</div>
			<div class="col-xs-1 grid-item-1">
				未检测到 : ${_detail.numFailure}
			</div>
			<div class="col-xs-1 grid-item-1">
				<span class="label label-success"> </span> : 所有指标正常
			</div>
			<div class="col-xs-1 grid-item-1">
				<span class="label label-warning"> </span> : 有异常指标
			</div>
			<div class="col-xs-1 grid-item-1">
				<span class="label label-danger"> </span> : 未检测到
			</div>
			<div class="col-xs-1 grid-item-1">
				<span class="label"> </span> : 忽略
			</div>
		</div>
		<div class="row">
			<c:forEach var="miner" items="${_detail.miners }">
			<div class="col-xs-1 detail-grid-item" onclick="window.open('http://${miner.ip}', '_blank')">
				<c:choose>
					<c:when test="${miner.flag == 3 }">
						<div class="panel panel-default detail-panel">
					</c:when>
					<c:otherwise>
						<c:choose>
							<c:when test="${miner.flag == 2 }">
								<div class="panel panel-danger detail-panel">
							</c:when>
							<c:otherwise>
								<c:choose>
									<c:when test="${miner.good == true }">
										<div class="panel panel-success detail-panel">
									</c:when>
									<c:otherwise>
										<div class="panel panel-warning detail-panel">
									</c:otherwise>
								</c:choose>
							</c:otherwise>
						</c:choose>
					</c:otherwise>
				</c:choose>
					<div class="panel-heading detail-panel-head" <c:if test="${miner.flag == 1 }">title="${miner.chains }"</c:if>>
						${miner.index }<br>
						<c:if test="${miner.flag == 1 }">
							型号 : ${miner.type } <br>
							算力 : <font <c:if test="${miner.goodHash == false }">color="red"</c:if>>${miner.hashReal }</font><br>
							风扇 : <font <c:if test="${miner.goodFanNum == false }">color="red"</c:if>>${miner.fanNumber }</font> / <font <c:if test="${miner.goodFanSpeed == false }">color="red"</c:if>>${miner.fanSpeed }</font><br>
							温度 : <font <c:if test="${miner.goodTempNum == false }">color="red"</c:if>>${miner.tempNumber }</font> / <font <c:if test="${miner.goodTempValue == false }">color="red"</c:if>>${miner.tempValue }</font><br>
							芯片 : <font <c:if test="${miner.goodChipNum == false }">color="red"</c:if>>${miner.chipNumber }</font><br>
							链条 : <font <c:if test="${miner.goodChainNum == false }">color="red"</c:if>>${miner.chainNumber }</font><br>
						</c:if>
					</div>
				</div>
			</div>
			</c:forEach>
		</div>
    </div>
	<%@include file="../_include/script.jsp" %>
	<script type="text/javascript">
		$(function() {
			var current = '${_currentShelfId}';
			if (current != '0') {
				$('#chosenShelfList').val(current);
			}
			$('#chosenShelfList').chosen({allow_single_deselect: true, width:'300px'});
			
			$('#btnDetect').on('click', function() {
				var sid = $('#chosenShelfList').val();
				window.location.href = 'realtime?sid=' + sid;
			});
		});
	</script>
</body>
</html>